package stalker;

import java.io.IOException;

import network.e2e.FrameReader;
import network.e2e.FrameWriter;

/**
 * Parser from the net that can retrieve or send a stalker
 */

public class StalkerParser {
  
  /**
   * Decode a stalker from the network
   * @requires reader not null
   * @param reader the net
   * @return the stalker read
   * @throws IOException 
   */
  public static Stalker retrieve(FrameReader reader) throws IOException {
    assert (reader != null);
    
    return Stalker.retrieveStalker(reader);
  }
  
  /**
   * Encode a stalker to be sent over the network
   * @requires param not null
   * @param stalker the content
   * @param writer  the net
   * @throws IOException 
   */
  public static void send(Stalker stalker, FrameWriter writer) throws IOException {
    assert stalker != null && writer != null;
    
    stalker.send(writer);
  }
  
}
